using System.ComponentModel.DataAnnotations;
using GroupSix.Domain.common;

namespace GroupSix.Application.Dtos;

/// <summary>
/// 用户权限请求DTO
/// </summary>
public class GetUserPermissionsRequestDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    [Required]
    public Guid UserId { get; set; }
}

/// <summary>
/// 用户权限响应DTO
/// </summary>
public class UserPermissionsResponseDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public Guid UserId { get; set; }

    /// <summary>
    /// 用户名
    /// </summary>
    public string Username { get; set; } = string.Empty;

    /// <summary>
    /// 用户角色列表
    /// </summary>
    public List<UserRoleDto> Roles { get; set; } = new();

    /// <summary>
    /// 可访问的菜单列表
    /// </summary>
    public List<MenuPermissionDto> Menus { get; set; } = new();

    /// <summary>
    /// 权限键列表
    /// </summary>
    public List<string> Permissions { get; set; } = new();
}

/// <summary>
/// 用户角色DTO
/// </summary>
public class UserRoleDto
{
    /// <summary>
    /// 角色ID
    /// </summary>
    public Guid Id { get; set; }

    /// <summary>
    /// 角色名称
    /// </summary>
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// 角色描述
    /// </summary>
    public string? Description { get; set; }
}

/// <summary>
/// 菜单权限DTO
/// </summary>
public class MenuPermissionDto
{
    /// <summary>
    /// 菜单ID
    /// </summary>
    public Guid Id { get; set; }

    /// <summary>
    /// 菜单名称
    /// </summary>
    public string Menuname { get; set; } = string.Empty;

    /// <summary>
    /// 菜单路径
    /// </summary>
    public string? MenuPath { get; set; }

    /// <summary>
    /// 菜单图标
    /// </summary>
    public string? MenuIcon { get; set; }

    /// <summary>
    /// 父菜单ID
    /// </summary>
    public Guid? ParentId { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Order { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    public string? PermissionKey { get; set; }

    /// <summary>
    /// 子菜单
    /// </summary>
    public List<MenuPermissionDto> Children { get; set; } = new();

    /// <summary>
    /// 是否有访问权限
    /// </summary>
    public bool HasAccess { get; set; }
}

/// <summary>
/// 权限验证请求DTO
/// </summary>
public class ValidatePermissionRequestDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    [Required]
    public Guid UserId { get; set; }

    /// <summary>
    /// 权限标识
    /// </summary>
    [Required]
    public string PermissionKey { get; set; } = string.Empty;

    /// <summary>
    /// 菜单路径（可选）
    /// </summary>
    public string? MenuPath { get; set; }
}

/// <summary>
/// 权限验证响应DTO
/// </summary>
public class ValidatePermissionResponseDto
{
    /// <summary>
    /// 是否有权限
    /// </summary>
    public bool HasPermission { get; set; }

    /// <summary>
    /// 消息
    /// </summary>
    public string Message { get; set; } = string.Empty;

    /// <summary>
    /// 用户角色
    /// </summary>
    public List<string> UserRoles { get; set; } = new();
}

/// <summary>
/// 获取用户菜单请求DTO
/// </summary>
public class GetUserMenusRequestDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    [Required]
    public Guid UserId { get; set; }
}

/// <summary>
/// 用户菜单响应DTO
/// </summary>
public class UserMenusResponseDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public Guid UserId { get; set; }

    /// <summary>
    /// 用户名
    /// </summary>
    public string Username { get; set; } = string.Empty;

    /// <summary>
    /// 菜单树
    /// </summary>
    public List<MenuPermissionDto> MenuTree { get; set; } = new();

    /// <summary>
    /// 总数量
    /// </summary>
    public int TotalCount { get; set; }
} 